package edu.iscas.appcheckclient.model.actions;

public class Screenshot extends Action{
    public static final String jsonName = "screenshot";
    protected boolean addTimestamp;
    protected String screenshotFilenamePrefix;
    protected Screenshot.Type type;

    public enum Type {
        Screenshot
    }

    public Screenshot(Screenshot.Type type, String screenshotFilenamePrefix, boolean addTimestamp) {
        this.name = "screenshot";
        this.type = type;
        this.screenshotFilenamePrefix = screenshotFilenamePrefix;
        this.addTimestamp = addTimestamp;
    }

    @Override
    public void setStatement(String statement) {
        this.statement = statement;
    }

    @Override
    public String brewStatement(boolean paramBoolean) {
        switch (type){
            case Screenshot:
                if(this.screenshotFilenamePrefix == null){
                    if(this.addTimestamp){
                        return "takeScreenshot()";
                    }
                    return "takeScreenshot(" + this.addTimestamp + ")";
                }
                if ((this.screenshotFilenamePrefix.equals("")) || (this.screenshotFilenamePrefix.equals("[PACKAGE]")))
                {
                    if (this.addTimestamp) {
                        return "takeScreenshot()";
                    }
                    return "takeScreenshot(" + this.addTimestamp + ")";
                }
                return "takeScreenshot(\"" + getScreenshotFilenamePrefix() + "\"," + this.addTimestamp + ")";
        }
        return null;
    }

    public boolean isAddTimestamp() {
        return addTimestamp;
    }

    public String getScreenshotFilenamePrefix() {
        return screenshotFilenamePrefix;
    }

    public Type getType() {
        return type;
    }

    @Override
    public String getTypeString() {
        return "screenshot";
    }

    @Override
    public String getValue() {
        return "";
    }

    public boolean equals(Object object){
        if(!(object instanceof Screenshot)){
            return false;
        }
        Screenshot other = (Screenshot)object;
        if(!(this.name.equals(other.name)) || !(this.type.equals(other.type))){
            return false;
        }
        return true;
    }
}
